package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.business.domain.ShopCommentsDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.ShopComments;
import com.ruoyi.business.service.ShopCommentsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**

 * 商铺评论Controller

 *

 * @author ruoyi

 * @date 2025-06-09
 */
@RestController
@RequestMapping("/system/comments")
public class ShopCommentsController extends BaseController
{
    @Autowired
    private ShopCommentsService tbShopCommentsService;

    /**

     * 查询商铺评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:comments:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopComments shopComments)
    {
        startPage();
        List<ShopCommentsDto> list = tbShopCommentsService.selectTbShopCommentsList(shopComments);
        return getDataTable(list);
    }

    /**

     * 导出商铺评论列表
     */
    @PreAuthorize("@ss.hasPermi('system:comments:export')")
    @Log(title = "商铺评论", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopComments shopComments)
    {
        List<ShopCommentsDto> list = tbShopCommentsService.selectTbShopCommentsList(shopComments);
        ExcelUtil<ShopCommentsDto> util = new ExcelUtil<ShopCommentsDto>(ShopCommentsDto.class);
        util.exportExcel(response, list, "商铺评论数据");
    }

    /**

     * 获取商铺评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:comments:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tbShopCommentsService.selectTbShopCommentsById(id));
    }

    /**

     * 新增商铺评论
     */
    @PreAuthorize("@ss.hasPermi('system:comments:add')")
    @Log(title = "商铺评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopComments shopComments)
    {
        return toAjax(tbShopCommentsService.insertTbShopComments(shopComments));
    }

    /**

     * 修改商铺评论
     */
    @PreAuthorize("@ss.hasPermi('system:comments:edit')")
    @Log(title = "商铺评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopComments shopComments)
    {
        return toAjax(tbShopCommentsService.updateTbShopComments(shopComments));
    }

    /**

     * 删除商铺评论,修改为逻辑删除
     */
    @PreAuthorize("@ss.hasPermi('system:comments:remove')")
    @Log(title = "商铺评论", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbShopCommentsService.deleteTbShopCommentsByIds(ids));
    }

    /**
     * 逻辑删除商铺评论
     */
}